<ul id="week_navigation">
  <li><?php echo link_to('<span>'.__('Prošla nedelja').'</span>', 'razred/dnevnik?razred_id='.$razred->getId().'&nedelja='.($nedelja-1), array('class' => 'button')) ?></li>
  <li><?php echo link_to('<span>'.__('Sledeća nedelja').'</span>', 'razred/dnevnik?razred_id='.$razred->getId().'&nedelja='.($nedelja+1), array('class' => 'button')) ?></li>
</ul>
<!--<div class="period">Period od <?php echo date('d.m.y.', strtotime($dani[0])) ?> do <?php echo date('d.m.y.', strtotime($dani[5])) ?></div>-->


<input type="hidden" id="razred_id" value="<?php echo $razred->getId() ?>" />

<table style="padding-left: 5px;" id="dnevnik_rada" border="1" cellpadding="0" cellspacing="0">
  <tr>
    <th rowspan="2" scope="col" class="small"><?php echo image_tag('/backend.php/utils/imageText/width/15/height/30/x/5/y/6/font/10/text/Dat') ?></th>
    <th colspan="10" scope="col">Časovi nastave</th>
    <th rowspan="2" scope="col">Izostali učenici<br /> ime i prezime</th>
    <th colspan="7" scope="col" class="small" style="width: 120px;">Izostanci</th>
    <th rowspan="2" scope="col" style="" class="small">Op</th>
    <th rowspan="2" scope="col" style="" class="small">Ne</th>
  </tr>
  <tr>
    <th>p</th>
    <th>0</th>
    <th>1</th>
    <th>2</th>
    <th>3</th>
    <th>4</th>
    <th>5</th>
    <th>6</th>
    <th>7</th>
    <th>8</th>
    <th class="izostanak">1</th>
    <th class="izostanak">2</th>
    <th class="izostanak">3</th>
    <th class="izostanak">4</th>
    <th class="izostanak">5</th>
    <th class="izostanak">6</th>
    <th class="izostanak">7</th>
  </tr>
<?php
$i = 0;
while($i++ < 6)
{?>
  <tr>
    <th rowspan="8" scope="row"><input type="hidden" id="dat_<?php echo $i ?>" value="<?php echo $dani[$i-1] ?>" />
      <p><?php echo image_tag('/backend.php/utils/imageText/width/15/height/70/x/5/y/6/font/12/text/'.date('d.m.y.', strtotime($dani[$i-1]))); ?></p>
      <p><?php if($i == 1) echo image_tag('/backend.php/utils/imageText/width/15/height/80/x/1/y/1/font/12/text/'.Functions::$dani[$i]);
               else echo image_tag('/backend.php/utils/imageText/width/15/height/70/x/5/y/6/font/12/text/'.Functions::$dani[$i]); ?></p>
    </th>
    <?php
    $j = -2;
    while($j++ < 8)
    {?>
    <td rowspan="8" id="cell_<?php echo $i.'_'.$j ?>" class="dnevnik_cas"><?php echo isset($cass[$i][$j]) ? Dnevnik::dnevnikUpisan($cass[$i][$j], $razred->getId()) : Dnevnik::dnevnikPrazan($i, $j, $rasporeds, $predmets) ?></td>
    <?php }?>
    <?php $k = 0;
    if(isset($izostanaks[$i]))
    foreach($izostanaks[$i] as $izostanak)
    {
      $k ++;
    ?>
      <td class="ime_ucenika"><?php echo ($iz = current($izostanak)) ? $iz->getColumn('RedBr').'. '.$iz->getColumn('UcenikPrezime').' '.$iz->getColumn('UcenikIme') : 'ax' ?></td>

      <?php
      $m = 0;
      $op = 0;
      $ne = 0;
      while($m++ < 7)
      {?>
      <td id="cell_izo_<?php echo $iz->getUcenikId().'_'.$i.'_'.$m ?>">
        <?php
          if(isset($izostanak[$m]))
          {
              $iz = $izostanak[$m];
              echo Dnevnik::izostanakUpisan($iz, $i, $m);
              if($iz->getOpravdan() == 1)
                $op++;
              else $ne ++;
          }
          else
            echo Dnevnik::noviIzostanak($i, $m, $iz->getUcenikId());
          ?>
        </td>
      <?php }?>

      <td id="op_izo_<?php echo $iz->getUcenikId().'_'.$i ?>" class="opravdano"><?php echo $op ?></td>
      <td id="ne_izo_<?php echo $iz->getUcenikId().'_'.$i ?>" class="neopravdano"><?php echo $ne ?></td>
      </tr>
    <?php
    }
    while($k++ < 8)
    {?>
      <td class="ime_ucenika" id="cell_uc_<?php echo $i.'_'.$k ?>"><?php echo select_tag('sel_uc_'.$i.'_'.$k, $ucenik_list, array("onchange" => "unesiUcenikIzostanak(this.id, this.value)")) ?></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      </tr>
  <?php }?>
<?php }?>

</table>
</div>